import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';

import {LoginComponent} from './main/login/login.component';
import {HomeComponent} from './main/home/home.component';

import {AuthGuard} from './guards/auth.guard';

const routes: Routes = [
  // 默认访问
  {path: '', redirectTo: 'login', pathMatch: 'full'},

  // 登录页
  {
    path: 'login', component: LoginComponent
  },
  // 主页
  {
    path: '', component: HomeComponent,
    canActivate: [AuthGuard],
    canDeactivate: [AuthGuard],
    children: [
      // 商品
      {
        path: 'goods',
        loadChildren: () => import('./main/goods/goods.module').then(m => m.GoodsModule),
      },
      // 订单
      {
        path: 'order',
        loadChildren: () => import('./main/order/order.module').then(m => m.OrderModule),
      },
      // 售后
      {
        path: 'service',
        loadChildren: () => import('./main/service/service.module').then(m => m.ServiceModule),
      },
      // 客户
      {
        path: 'customer',
        loadChildren: () => import('./main/customer/customer.module').then(m => m.CustomerModule),
      },
      // 营销
      {
        path: 'sell',
        loadChildren: () => import('./main/sell/sell.module').then(m => m.SellModule),
      },
      // 库存
      {
        path: 'stock',
        loadChildren: () => import('./main/stock/stock.module').then(m => m.StockModule),
      },
      // 配置
      {
        path: 'config',
        loadChildren: () => import('./main/config/config.module').then(m => m.ConfigModule),
      },
      // 系统
      {
        path: 'system',
        loadChildren: () => import('./main/system/system.module').then(m => m.SystemModule),
      },
      // 二手回收
      {
        path: 'recycle',
        loadChildren: () => import('./main/recycle/recycle.module').then(m => m.RecycleModule),
      },
      // 爱乐app
      {
        path: 'ihapp',
        loadChildren: () => import('./main/ihapp/ihapp.module').then(m => m.ihappModule),
      },
      // 财务明细
      {
        path: 'finance',
        loadChildren: () => import('./main/finance/finance.module').then(m => m.financeModule),
      },
      // 爱定制
      {
        path: 'customization',
        loadChildren: () => import('./main/customization/customization.module').then(m => m.CustomizationModule),
      },
      // 推广分成
      {
        path: 'promotionshare',
        loadChildren: () => import('./main/promotionShare/promotion-share.module').then(m => m.PromotionShareModule),
      },
      // 爱思报价
      {
        path: 'aisi-price',
        loadChildren: () => import('./main/aisi-price/aisi-price.module').then(m => m.AisiPriceModule),
      },
      // 客户管理
      {
        path: 'customer-manage',
        loadChildren: () => import('./main/customer-manage/customer-manage.module').then(m => m.CustomerManageModule),
      },
      // 商家圈子
      {
        path: 'business-circle',
        loadChildren: () => import('./main/business-circle/business-circle.module').then(m => m.BusinessCircleModule),
      },
      // 爱思回收
      {
        path: 'aisi-recyc',
        loadChildren: () => import('./main/love-recyc-manage/love-recyc-manage.module').then(m => m.LoveRecycManageModule),
      },
      // 合作管理
      {
        path: 'cooperation',
        loadChildren: () => import('./main/cooperation/cooperation.module').then(m => m.CooperationModule),
      },
      // 二手商城
      {
        path: 'used-store',
        loadChildren: () => import('./main/used-store/used-store.module').then(m => m.UsedStoreModule),
      },
      // 维修图纸
      {
        path: 'maintain-blueprint',
        loadChildren: () => import('./main/maintainBlueprint/maintain-blueprint.module').then(m => m.MaintainBlueprintModule),
      },
      // 充值专区
      {
        path: 'recharge',
        loadChildren: () => import('./main/recharge/recharge.module').then(m => m.RechargeModule),
      },
      // 普普优品
      {
        path: 'PPYP',
        loadChildren: () => import('./main/ppyp/ppyp.module').then(m => m.PpypModule),
      },
      // 仓储中心
      {
        path: 'storage-center',
        loadChildren: () => import('./main/storage-manage/storage-manage.module').then(m => m.StorageManageModule),
      },
      // 仓储中心
      {
        path: 'hireDevice',
        loadChildren: () => import('./main/hireDeviceManage/hireDevice.module').then(m => m.HireDeviceModule),
      },
      // B2B商城
      {
        path: 'b2b',
        loadChildren: () => import('./main/b2b/b2b.module').then(m => m.B2bModule),
      },
    ]
  },
  // 通配符 通常指向404页面
  // { path: '**', redirectTo: '/goods' },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {
}
